﻿using PLCTest.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PLCTest.BO
{
    public class PlanarPuDoPlcActionBO
    {
        /// <summary>
        /// 设备号
        /// </summary>
        public string EquipmentCode { get; set; }
        /// <summary>
        /// 任务号1
        /// </summary>
        public int TaskCode_1 { get; set; }
        /// <summary>
        /// 目标设备号1
        /// </summary>
        public int ToEquipmentCode_1 { get; set; }
        /// <summary>
        /// 托盘码1
        /// </summary>
        public string PalletBarcode_1 { get; set; }
        /// <summary>
        /// 握手类型1
        /// </summary>
        public short ActionType_1 { get; set; }
        /// <summary>
        /// 托盘类型1
        /// </summary>
        public byte PalletType_1 { get; set; }
        /// <summary>
        /// 报警代码1
        /// </summary>
        public byte AlrmCode_1 { get; set; }

        /// <summary>
        /// 单机任务标识1
        /// </summary>
        public byte Reserve_1 { get; set; }
        /// <summary>
        /// 预留2_1
        /// </summary>
        public byte Reserve2_1 { get; set; }
        /// <summary>
        /// 预留3_1
        /// </summary>
        public byte Reserve3_1 { get; set; }
        /// <summary>
        /// 预留4_2
        /// </summary>
        public byte Reserve4_1 { get; set; }



        /// <summary>
        /// 设备号2  无用 不写设备号
        /// </summary>
        public string EquipmentCode_2 { get; set; }
        /// <summary>
        /// 任务号2
        /// </summary>
        public int TaskCode_2 { get; set; }
        /// <summary>
        /// 目标设备号2
        /// </summary>
        public int ToEquipmentCode_2 { get; set; }
        /// <summary>
        /// 托盘码2
        /// </summary>
        public string PalletBarcode_2 { get; set; }
        /// <summary>
        /// 握手类型2
        /// </summary>
        public short ActionType_2 { get; set; }
        /// <summary>
        /// 托盘类型2
        /// </summary>
        public byte PalletType_2 { get; set; }
        /// <summary>
        /// 报警代码2
        /// </summary>
        public byte AlrmCode_2 { get; set; }

        /// <summary>
        /// 单机任务标识2
        /// </summary>
        public byte Reserve_2 { get; set; }
        /// <summary>
        /// 预留2_2
        /// </summary>
        public byte Reserve2_2 { get; set; }
        /// <summary>
        /// 预留3_2
        /// </summary>
        public byte Reserve3_2 { get; set; }
        /// <summary>
        /// 预留4_2
        /// </summary>
        public byte Reserve4_2 { get; set; }

        public void Serialize(byte[] bytes)
        {
            //工位1信息
            EquipmentCode = HelperByte.GetDIntAt(bytes, 0).ToString();
            TaskCode_1 = HelperByte.GetDIntAt(bytes, 4);
            ToEquipmentCode_1 = HelperByte.GetDIntAt(bytes, 8);
            int length = HelperByte.GetSIntAt(bytes, 13);
            PalletBarcode_1 = HelperByte.GetCharsAt(bytes, 14, length);
            ActionType_1 = HelperByte.GetIntAt(bytes, 32);
            PalletType_1 = HelperByte.GetByteAt(bytes, 34);
            AlrmCode_1 = HelperByte.GetByteAt(bytes, 35);
            Reserve_1 = HelperByte.GetByteAt(bytes, 36);//单机任务标志
            Reserve2_1 = HelperByte.GetByteAt(bytes, 37);
            Reserve3_1 = HelperByte.GetByteAt(bytes, 38);
            Reserve4_1 = HelperByte.GetByteAt(bytes, 39);

            //工位2信息
            EquipmentCode_2 = HelperByte.GetDIntAt(bytes, 40).ToString();
            TaskCode_2 = HelperByte.GetDIntAt(bytes, 44);
            ToEquipmentCode_2 = HelperByte.GetDIntAt(bytes, 48);
            int length2 = HelperByte.GetSIntAt(bytes, 53);
            PalletBarcode_2 = HelperByte.GetCharsAt(bytes, 54, length2);
            ActionType_2 = HelperByte.GetIntAt(bytes, 72);
            PalletType_2 = HelperByte.GetByteAt(bytes, 74);
            AlrmCode_2 = HelperByte.GetByteAt(bytes, 75);
            Reserve_2 = HelperByte.GetByteAt(bytes, 76);//单机任务标志
            Reserve2_2 = HelperByte.GetByteAt(bytes, 77);
            Reserve3_2 = HelperByte.GetByteAt(bytes, 78);
            Reserve4_2 = HelperByte.GetByteAt(bytes, 79);

        }
    }
}
